package com.woniu.mgr.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.woniu.mgr.common.Result;
import com.woniu.mgr.model.CoachApply;
import com.woniu.mgr.service.CoachApplyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 教练登记申请表 前端控制器
 * </p>
 *
 * @author Silas
 * @since 2023-02-15
 */
@RestController
@RequestMapping("/coachApply")
@Slf4j
public class CoachApplyController {
    @Resource
    private CoachApplyService coachApplyService;

    @PostMapping("/successBeCoach")
    public Result successBeCoach(@RequestBody Integer coachApplyId) {
        log.info("成为教练申请通过{}", coachApplyId);
        coachApplyService.successBeCoach(coachApplyId);
        return Result.success(200, "申请成功", null);
    }

    @GetMapping("/query")
    public Result query(String condition, Integer current, Integer size) {
        log.info("查看所有教练申请");
        IPage<CoachApply> page = coachApplyService.query(condition, current, size);
        return Result.success(200, "查询成功", page);
    }
    @PostMapping("/agree")
    public Result agree(Integer coachApplyId){
        log.info("{}通过申请",coachApplyId);
       coachApplyService.successBeCoach(coachApplyId);
       return Result.success(200,"success",null);
    }
    @PostMapping("/refuse")
    public Result refuse(String message,Integer coachApplyId){
        log.info("{}未通过申请,原因:{}",coachApplyId,message);
        coachApplyService.refuse(message,coachApplyId);
        return Result.success(200,"success",null);
    }


}

